﻿using System;
using System.Collections.Generic;

namespace UniSender
{
    using IValues = IDictionary<string, string>;
    using Values = Dictionary<string, string>;

    public class Subscription
    {
        public virtual long ListId { get; set; }
        public virtual DateTime Time { get; set; }

        public Subscription()
        { }

        public Subscription(long listId, DateTime time)
        {
            ListId = listId;
            Time = time;
        }
    }

    public abstract class Contact
    {
        public virtual string Value { get; set; }
        public virtual ContactStatus? Status { get; set; }
        public virtual ContactAvailability? Availability { get; set; }
        public virtual DateTime? AddTime { get; set; }
        public virtual string RequestIP { get; set; }
        public virtual Subscription[] Subscriptions { get; set; }
        public virtual long[] UnsubscribedListIds { get; set; }
        public virtual long[] ExcludedListIds { get; set; }

        public Contact(string value)
        {
            Value = value;
        }
    }

    public class EmailContact : Contact
    {
        public virtual string ConfirmIP { get; set; }
        public virtual DateTime? ConfirmTime { get; set; }

        public EmailContact(string email) : base(email) { }
    }

    public class PhoneContact : Contact
    {
        public PhoneContact(string phone) : base(phone) { }
    }

    public class Subscriber
    {
        protected Values custom = new Values();

        public virtual EmailContact Email { get; set; }

        public virtual PhoneContact Phone { get; set; }

        public virtual string[] Tags { get; set; }

        public virtual IValues Custom
        {
            get { return custom; }
            set { custom.Update(value); }
        }
    }
}
